package tt.dz.egobus.servicemanager.business.convert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.core.convert.converter.Converter;
import tt.dz.egobus.servicemanager.bean.CornConverter;
import tt.dz.egobus.servicemanager.vo.BusServiceViewVo;

/**
 * @author Anson
 * @date 17-8-30
 * @name busServiceView <-> jsonObject
 * @since 1.0.7
 */
public class BusServiceViewCornConvert implements CornConverter<BusServiceViewVo, JSONObject> {


    @Override
    public Converter<BusServiceViewVo, JSONObject> convertCornA() {
        return new Converter<BusServiceViewVo, JSONObject>() {
            @Override
            public JSONObject convert(BusServiceViewVo source) {
                return (JSONObject) JSON.toJSON(source);
            }
        };
    }

    @Override
    public Converter<JSONObject, BusServiceViewVo> convertCornB() {
        return new Converter<JSONObject, BusServiceViewVo>() {
            @Override
            public BusServiceViewVo convert(JSONObject source) {
                return JSONObject.toJavaObject(source, BusServiceViewVo.class);
            }
        };
    }
}
